﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MvcShop.Extensions.Html;
using System.Web.Mvc;

namespace MvcShop.Models.ViewDataModels
{
    public class FrontProductViewData
    {
        #region ==== Property =====
        public int PageIndex { get; set; }
        public int Count { get; set; }
        public int Total { get; set; }
        public string KeyWord { get; set; }
        public PositionType PositionType { get; set; }
        public Dictionary<string,object> Parameters { get; set; }
        public SelectList ProductOrder { get; set; }

        public Category Category { get; set; }
        public IEnumerable<Category> Categories { get; set; }

        public IEnumerable<ShowListProductModel> ShowListProductModels { get; set; }

        public IEnumerable<ShowBoxProductModel> ShowBoxProductModels { get; set; }

        public Product Product { get; set; }
        public IEnumerable<Product> Products { get; set; }

        public Product_property Product_property { get; set; }
        public IEnumerable<Product_property> Product_properties { get; set; }

        public Product_propertys_content Product_propertys_content { get; set; }
        public IEnumerable<Product_propertys_content> Product_propertys_contents { get; set; }

        public Product_Image Product_Image { get; set; }
        public IEnumerable<Product_Image> Product_Images { get; set; }
        public IEnumerable<FrontProductImage> FrontProductImages { get; set; }

        public Remark Remark { get; set; }
        public IEnumerable<Remark> Remarks { get; set; }
        public int RemarkCount { get; set; }

        public PPCModel PPCModel { get; set; }
        public IEnumerable<PPCModel> PPCModels { get; set; }

        public IEnumerable<ProductList> ProductList { get; set; }

        public IEnumerable<FProductList> FProductList { get; set; }
        #endregion

        #region ==== Methods ====
        public FrontProductViewData WithPageIndex(int pageIndex)
        {
            this.PageIndex = pageIndex;
            return this;
        }

        public FrontProductViewData WithCount(int count)
        {
            this.Count = count;
            return this;
        }

        public FrontProductViewData WithTotal(int pageSize)
        {
            this.Total = Math.Max((this.Count + pageSize - 1) / pageSize, 1); ;
            return this;
        }

        public FrontProductViewData WithKeyWord(string keyWord)
        {
            this.KeyWord = keyWord;
            return this;
        }

        public FrontProductViewData WithPositionType(PositionType positionType)
        {
            this.PositionType = positionType;
            return this;
        }

        public FrontProductViewData WithParameters(Dictionary<string, object> parameters)
        {
            this.Parameters = parameters;
            return this;
        }

        public FrontProductViewData WithProductOrder(SelectList productOrder)
        {
            this.ProductOrder = productOrder;
            return this;
        }

        public FrontProductViewData WithCategory(Category category)
        {
            this.Category = category;
            return this;
        }

        public FrontProductViewData WithCategories(IEnumerable<Category> categorise)
        {
            this.Categories = categorise;
            return this;
        }

        public FrontProductViewData WithShowListProductModels(IEnumerable<ShowListProductModel> showListProductModels)
        { 
            this.ShowListProductModels = showListProductModels;
            return this;
        }

        public FrontProductViewData WithShowBoxProductModel(IEnumerable<ShowBoxProductModel> showBoxProductModels)
        {
            this.ShowBoxProductModels = showBoxProductModels;
            return this;
        }

        public FrontProductViewData WithProduct(Product product)
        {
            this.Product = product;
            return this;
        }

        public FrontProductViewData WithProducts(IEnumerable<Product> products)
        {
            this.Products = products;
            return this;
        }

        public FrontProductViewData WithProduct_property(Product_property propery)
        {
            this.Product_property = propery;
            return this;
        }

        public FrontProductViewData WithProduct_propertis(IEnumerable<Product_property> properies)
        {
            this.Product_properties = properies;
            return this;
        }

        public FrontProductViewData WithProduct_propertys_content(Product_propertys_content content)
        {
            this.Product_propertys_content = content;
            return this;
        }

        public FrontProductViewData WithProduct_propertys_contents(IEnumerable<Product_propertys_content> contents)
        {
            this.Product_propertys_contents = contents;
            return this;
        }

        public FrontProductViewData WithProduct_Image(Product_Image image)
        {
            this.Product_Image = image;
            return this;
        }

        public FrontProductViewData WithProduct_Images(IEnumerable<Product_Image> images)
        {
            this.Product_Images = images;
            return this;
        }

        public FrontProductViewData WithFrontProductImages(IEnumerable<FrontProductImage> frontProductImages)
        {
            this.FrontProductImages = frontProductImages;
            return this;
        }

        public FrontProductViewData WithRemark(Remark remark)
        {
            this.Remark = remark;
            return this;
        }

        public FrontProductViewData WithRemarks(IEnumerable<Remark> remarks)
        {
            this.Remarks = remarks;
            return this;
        }

        public FrontProductViewData WithRemarkCount(int remarkCount)
        {
            this.RemarkCount = remarkCount;
            return this;
        }

        public FrontProductViewData WithPPCModel(PPCModel ppcModel)
        {
            this.PPCModel = ppcModel;
            return this;
        }

        public FrontProductViewData WithPPCModels(IEnumerable<PPCModel> ppcModels)
        {
            this.PPCModels = ppcModels;
            return this;
        }

        public FrontProductViewData WithProductList(IEnumerable<ProductList> productList)
        {
            this.ProductList = productList;
            return this;
        }

        public FrontProductViewData WithFProductList(IEnumerable<FProductList> fProductList)
        {
            this.FProductList = fProductList;
            return this;
        }
        #endregion
    }

    /// <summary>
    /// 创建新的FrontProductViewData类
    /// </summary>
    public static class FrontProductsView
    {
        public static FrontProductViewData Data { get { return new FrontProductViewData(); } }
    }
}
